/**
*      author: Y_Yao
*      created: 2024-10-16 16:54:44
**/

#include<bits/stdc++.h>

#define lc p<<1
#define rc p<<1|1
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 7;
LL a[N];

struct node
{
    LL l,r,sum;
}tr[N * 4];

void pushup(LL p)
{
    tr[p].sum = tr[lc].sum + tr[rc].sum;
}

void build(LL p,LL l,LL r)
{
    tr[p] = {l,r,a[l]};
    if(l == r) return;

    LL mid = (l + r) >> 1;
    build(lc,l,mid);
    build(rc,mid + 1,r);
    pushup(p);
}

void update(LL p,LL x,LL y)
{
    if(tr[p].sum  == tr[p].r - tr[p].l + 1) return;
    if(tr[p].l == tr[p].r)
    {
        tr[p].sum = sqrt(tr[p].sum);
        return;
    }

    LL mid = (tr[p].l + tr[p].r) >> 1;
    if(x <= mid) update(lc,x,y);
    if(y > mid) update(rc,x,y);
    pushup(p);
}

LL qurey(LL p,LL x,LL y)
{
    if(x <= tr[p].l && tr[p].r <= y)
    {
        return tr[p].sum;
    }

    LL mid = (tr[p].l + tr[p].r) >> 1;
    LL sum = 0;
    if(x <= mid) sum += qurey(lc,x,y);
    if(y > mid) sum += qurey(rc,x,y);
    return sum;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    LL n;
    int cnt = 1;
    while(cin >> n)
    {
        cout << "Case #" << cnt++ << ":" << endl;
        for(LL i = 1;i <= n;i++) cin >> a[i];
        build(1,1,n);

        LL m = 0;
        cin >> m;
        for(int i = 1;i <= m;i++)
        {
            LL t,x,y;
            cin >> t >> x >> y; 
            if(x > y) swap(x,y);
            if(t == 0)
            {
                    update(1,x,y);
            }
            else if(t == 1)
            {
                LL out = qurey(1,x,y);
                cout << out << endl;
            }
        }
    }
    return 0;
} 